import 'package:auto_size_text/auto_size_text.dart';
import 'package:cached_network_image/cached_network_image.dart';
import 'package:flutter/material.dart';
import 'package:sabre_sync_fencing/dd_core/dd_other.dart';

import '../../../dd_models/dd_hive_works_model.dart';
import '../../../r.dart';
import '../controllers/dd_block_list_controller.dart';
import '../controllers/dd_my_follow_controller.dart';
import 'dd_view_background.dart';

class DDMyBlockCell extends StatefulWidget {
  final BlockUser model;
  final Function()? onClick;
  final String? title;
  const DDMyBlockCell(
      {Key? key, required this.model, this.onClick, this.title = 'Unblock'})
      : super(key: key);

  @override
  State<DDMyBlockCell> createState() => _DDMyBlockCellState();
}

class _DDMyBlockCellState extends State<DDMyBlockCell> {
  @override
  void initState() {
    super.initState();
  }

  @override
  Future<void> dispose() async {
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return Container(
      margin: EdgeInsets.only(left: 0, right: 20, top: 10, bottom: 10),
      child: Row(
        crossAxisAlignment: CrossAxisAlignment.center,
        children: [
          ClipRRect(
            borderRadius: BorderRadius.circular(16.0),
            child: CachedNetworkImage(
              width: 32,
              height: 32,
              imageUrl: widget.model.avatar ?? '',
              placeholder: (context, url) => Placeholder(),
              errorWidget: (context, url, error) => Placeholder(),
            ),
          ),
          SizedBox(width: 8),
          Expanded(
              child: Column(
            crossAxisAlignment: CrossAxisAlignment.start,
            children: [
              Text(
                widget.model.nickName ?? '',
                maxLines: 1,
                style: TextStyle(
                    fontWeight: FontWeight.bold,
                    fontSize: 14,
                    color: Color(0xFF202020)),
              ),
              AutoSizeText(
                '${widget.model.age} ${widget.model.registerCountry}' ,
                maxLines: 1,
                minFontSize: 8,
                style: TextStyle(
                    fontWeight: FontWeight.bold,
                    fontSize: 12,
                    color: Color(0x80000000)),
              ),
            ],
          )),
          SizedBox(width: 10),
          DDViewBackGround(
            borderWidth : 1,
            content: DDSafeButton(
              onPressed: () {
                widget.onClick!();
              },
              child: Container(
                padding:
                    EdgeInsets.only(left: 12, right: 12, top: 6, bottom: 6),
                child: Text(
                  widget.title ?? '',
                  style: TextStyle(fontSize: 12, color: Color(0xFF565656)),
                ),
              ),
            ),
          ),
        ],
      ),
    );
  }
}



class DDMyFollowCell extends StatefulWidget {
  final FollowUser model;
  final Function()? onClick;
  final String? title;
  const DDMyFollowCell(
      {Key? key, required this.model, this.onClick, this.title = 'Unblock'})
      : super(key: key);

  @override
  State<DDMyFollowCell> createState() => _DDMyFollowCellState();
}

class _DDMyFollowCellState extends State<DDMyFollowCell> {
  @override
  void initState() {
    super.initState();
  }

  @override
  Future<void> dispose() async {
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return Container(
      margin: EdgeInsets.only(left: 0, right: 20, top: 10, bottom: 10),
      child: Row(
        crossAxisAlignment: CrossAxisAlignment.center,
        children: [
          ClipRRect(
            borderRadius: BorderRadius.circular(16.0),
            child: CachedNetworkImage(
              width: 32,
              height: 32,
              imageUrl: widget.model.avatarUrl ?? '',
              placeholder: (context, url) => Placeholder(),
              errorWidget: (context, url, error) => Placeholder(),
            ),
          ),
          SizedBox(width: 8),
          Expanded(
              child: Column(
                crossAxisAlignment: CrossAxisAlignment.start,
                children: [
                  Text(
                    widget.model.nickname ?? '',
                    maxLines: 1,
                    style: TextStyle(
                        fontWeight: FontWeight.bold,
                        fontSize: 14,
                        color: Color(0xFF202020)),
                  ),
                  AutoSizeText(
                    '${widget.model.age} ${widget.model.country}' ,
                    maxLines: 1,
                    minFontSize: 8,
                    style: TextStyle(
                        fontWeight: FontWeight.bold,
                        fontSize: 12,
                        color: Color(0x80000000)),
                  ),
                ],
              )),
          SizedBox(width: 10),
          DDViewBackGround(
            borderWidth : 1,
            content: DDSafeButton(
              onPressed: () {
                widget.onClick!();
              },
              child: Container(
                padding:
                EdgeInsets.only(left: 12, right: 12, top: 6, bottom: 6),
                child: Text(
                  widget.title ?? '',
                  style: TextStyle(fontSize: 12, color: Color(0xFF565656)),
                ),
              ),
            ),
          ),
        ],
      ),
    );
  }
}
